package com.csun.cmny.provider.service.impl;

import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.DmcPhoneDataHiMapper;
import com.csun.cmny.provider.model.domain.DmcPhoneDataHi;
import com.csun.cmny.provider.model.dto.phone.PhoneDataHiPageQuery;
import com.csun.cmny.provider.service.DmcPhoneDataHiService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-01-09 18:03
 * @Description:
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class DmcPhoneDataHiServiceImpl extends BaseService<DmcPhoneDataHi> implements DmcPhoneDataHiService {

    @Resource
    private DmcPhoneDataHiMapper dmcPhoneDataHiMapper;

    /**
     * query dmc phone data hi list with page
     *
     * @param phoneDataHiPageQuery the phone data hi query page
     *
     * @return the page info
     */
    @Override
    public PageInfo queryDmcPhoneDataHiListWithPage(PhoneDataHiPageQuery phoneDataHiPageQuery) {

        PageHelper.startPage(phoneDataHiPageQuery.getPageNum(), phoneDataHiPageQuery.getPageSize());

        List<DmcPhoneDataHi> phoneDataHiList = dmcPhoneDataHiMapper.queryDmcPhoneDataHiListWithPage(phoneDataHiPageQuery);

        return new PageInfo<>(phoneDataHiList);
    }

    /**
     * insert dmc phone data hi
     *
     * @param dmcPhoneDataHi the dmc phone data hi
     * @return the int
     */
    @Override
    public Integer insertDmcPhoneDataHi(DmcPhoneDataHi dmcPhoneDataHi) {
        return null;
    }

    /**
     * delete dmc phone data hi by device id
     *
     * @param deviceId the device id
     * @return the int
     */
    @Override
    public Integer deleteDmcPhoneDataHiByDeviceId(Long deviceId) {

        DmcPhoneDataHi dmcPhoneDataHi = new DmcPhoneDataHi();
        dmcPhoneDataHi.setDeviceId(deviceId);

        return dmcPhoneDataHiMapper.delete(dmcPhoneDataHi);
    }
}
